<template>
  <view class="container">
    <!-- <div style="padding: 20rpx; background-color: white">
      <view class="example-body">
        <uni-datetime-picker v-model="datetimerange" type="datetimerange" rangeSeparator="至" />
      </view>
    </div> -->

    <view style="height: 40rpx;"></view>


    <z-paging class="container" ref="paging" v-model="dataList" @query="queryList">



      <div class="order_card" v-for="item in dataList" :key="item.id">
        <div class="order_card_title" style="margin-left: 30rpx">设备信息</div>

        <div class="order_card_content">
          <div class="order_card_item">
            <div class="order_card_item_title">设备名称</div>
            <div class="order_card_item_value">{{ item.equipment.scene_type === 1 ? "陪诊床" : "轮椅" }}</div>
          </div>

          <div class="order_card_item">
            <div class="order_card_item_title">设备编号</div>
            <div class="order_card_item_value">{{ item.equipment.device_id }}</div>
          </div>

          <div class="order_card_item">
            <div class="order_card_item_title">机构</div>
            <div class="order_card_item_value">{{ item.hospital.name }}</div>
          </div>

          <!-- <div class="order_card_item">
            <div class="order_card_item_title">科室</div>
            <div class="order_card_item_value">测试科室</div>
          </div>

          <div class="order_card_item">
            <div class="order_card_item_title">楼层</div>
            <div class="order_card_item_value">999</div>
          </div> -->

          <div class="order_card_item">
            <div class="order_card_item_title">巡检人</div>
            <div class="order_card_item_value">{{ item.user.nickname }}</div>
          </div>

          <div class="order_card_item">
            <div class="order_card_item_title">巡检日期</div>
            <div class="order_card_item_value">{{ timeStampToTime(item.inspection_time) }}</div>
          </div>
        </div>
      </div>
    </z-paging>



  </view>
</template>

<script>
import { getStatistics } from "@/api/index.js";
import navbarMixin from "@/common/mixin/navbar.js";
import { inspection } from "../../../api";
import dayjs from "dayjs";
export default {
  mixins: [navbarMixin],

  data() {
    return {
      content: "",
      keyword: "",
      show: false,
      datetimerange: [],
      dataList: [],
    };
  },

  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad(options) {
    this.getData();
  },

  methods: {

    timeStampToTime(timestamp) {
      return dayjs(timestamp * 1000).format("YYYY-MM-DD HH:mm:ss");
    },

    queryList(pageNo, pageSize) {
      const app = this;

      // 此处请求仅为演示，请替换为自己项目中的请求
      inspection({ page: pageNo, limit: pageSize, hospital_id: uni.getStorageSync("curHospital"), }).then(res => {

        app.total = res.total;

        // 将请求结果通过complete传给z-paging处理，同时也代表请求结束，这一行必须调用
        app.$refs.paging.complete(res.list);
      }).catch(res => {
        console.log('res', res);

        // 如果请求失败写this.$refs.paging.complete(false)，会自动展示错误页面
        // 注意，每次都需要在catch中写这句话很麻烦，z-paging提供了方案可以全局统一处理
        // 在底层的网络请求抛出异常时，写uni.$emit('z-paging-error-emit');即可
        app.$refs.paging.complete(false);
      })
    },


    /**
     * 返回上一页
     */
    goBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background: #ebebeb;
}

.order_card {
  background-color: white;
  margin-bottom: 30rpx;
  padding-top: 30rpx;
}

.order_card_content {
  padding: 30rpx 30rpx 20rpx 30rpx;
}

.order_card_item {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding-right: 33rpx;

  margin-bottom: 20rpx;

  .order_card_item_title {
    color: rgba(180, 180, 180, 1);
    font-size: 32rpx;
    text-align: left;
    font-family: SourceHanSansSC-regular;
  }

  .order_card_item_value {
    color: rgba(0, 0, 0, 1);
    font-size: 32rpx;
    text-align: right;
    font-family: SourceHanSansSC-regular;
  }
}
</style>
